package com.zr.gdms.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zr.gdms.service.LogService;
import com.zr.gdms.serviceimpl.LogServiceImpl;

import net.sf.json.JSONObject;

public class SearchLogByDateControllerLPN extends HttpServlet{

	LogService ls = new LogServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doPost(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("utf8");
		resp.setCharacterEncoding("utf8");
		int page = Integer.parseInt(req.getParameter("page"));
		int rows  = Integer.parseInt(req.getParameter("rows"));
		HttpSession  session = req.getSession();
		String year = req.getParameter("year");
		String month = req.getParameter("month");
		String day = req.getParameter("day");
		JSONObject j = ls.searchLogByDate(page, rows, year, month, day);
		session.setAttribute("log", j);
		PrintWriter pw = resp.getWriter();
		pw.write(j.toString());
		pw.flush();
		pw.close();
	}
}
